﻿using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
using MasterDetailTemplate.Models;

namespace MasterDetailTemplate.Services
{
    public interface IDietRecorderStorageService
    {
        /// <summary>
        /// 初始数据库
        /// </summary>
        /// <returns></returns>
        Task InitializeAsync();

        /// <summary>
        /// 数据库时候初始化
        /// </summary>
        /// <returns></returns>
        bool IsInitialized();

        /// <summary>
        /// 根据id查找菜品
        /// </summary>
        /// <param name="dietId">诗词id</param>
        /// <returns></returns>
        Task<DietRecorder> GetDietRecorderAsync(int id);

        Task Insert(DietRecorder dietRecorder);

        /// <summary>
        /// 增加一组记录
        /// </summary>
        /// <param name="dietRecorders"></param>
        /// <returns></returns>
        Task InsertAll(List<DietRecorder> dietRecorders);

        /// <summary>
        /// 根据条件获取菜品列表
        /// </summary>
        /// <param name="where"></param>
        /// <param name="skip"></param>
        /// <param name="take"></param>
        /// <returns></returns>
        Task<List<DietRecorder>> GetDietRecordersAsync(
            Expression<Func<DietRecorder, bool>> where, int skip, int take);

        /// <summary>
        /// 获取满足条件的所有
        /// </summary>
        /// <param name="where"></param>
        /// <returns></returns>
        Task<List<DietRecorder>> GetAllDietRecorderAsync(
            Expression<Func<DietRecorder, bool>> where);

        Task CloseConnection();
    }

    public static class DietRecorderStorageConstants {
        public const int VERSION = 1;
        public const int DEFAULTVERSION = -1;

        public const string VersionKey = nameof(DietRecorderStorageConstants) +
            "." + nameof(VERSION);
    }
}
